#include <bits/stdc++.h>
#define F(i, a, b) for (int i = (a); i <= (b); ++i)
#define dF(i, a, b) for (int i = (a); i >= (b); --i)

using namespace std;
typedef long long LL;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pii;
const int N = 1e5 + 5;
const int K = 1e6 + 5;

int n, m, L, V, d[N], v[N], a[N];
int p[N], t[K], mn[N], w, q[N];
vector<int> qu[N]; int cnt, ans;

void mian() {
  cin >> n >> m >> L >> V, ++L, w = cnt = ans = 0;
  F(i, 1, n) cin >> d[i] >> v[i] >> a[i], ++d[i];
  F(i, 1, m) cin >> p[i], ++t[++p[i]], q[++w] = p[i];
  sort(q + 1, q + w + 1), w = unique(q + 1, q + w + 1) - q - 1;
  F(i, 1, L) t[i] += t[i - 1];
  F(i, 1, w) mn[i] = w + 1;
  F(i, 1, n) {
    int ql = d[i], qr = L;
    double del = (V * V - v[i] * v[i]) / 2.0 / a[i];
    if (a[i] > 0) ql = max(ql, d[i] + (int) floor(del) + 1);
    if (a[i] < 0) qr = min(qr, d[i] + (int) ceil(del) - 1);
    if (!a[i]) if (v[i] <= V || !(t[L] - t[d[i] - 1])) ql = L + 1;
    if (ql <= qr && t[qr] - t[ql - 1]) {
      ql = lower_bound(q + 1, q + w + 1, ql) - q;
      qr = upper_bound(q + 1, q + w + 1, qr) - q - 1;
      ++cnt, mn[ql] = min(mn[ql], qr);
    }
  }
  cout << cnt << " ";
  int lst = -1, lim = -1;
  F(i, 1, w) if (mn[i] <= w && lst < i)
    if (lim < i) ++ans, lst = i, lim = mn[i];
    else lst = i, lim = min(lim, mn[i]);
  cout << m - ans << "\n";
  F(i, 1, w) qu[i].clear(); F(i, 1, L) t[i] = 0;
}

int main() {
  freopen("detect.in", "r", stdin);
  freopen("detect.out", "w", stdout);
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int _; cin >> _; while (_--) mian();
  return 0;
}